package com.tofix.kidmall.entity;


import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * @author wu
 * @description 购物车表
 * @data 2020/6/3
 **/

@Data
@Entity
@Table(name = "t_cart")
public class Cart implements Serializable {
    @Id
    @GenericGenerator(name = "cartid", strategy = "uuid")
    //@GeneratedValue(strategy = GenerationType.AUTO)
    @GeneratedValue(generator = "cartid")
    private String cartId;
    private String userId;

    @JsonIgnore
    @ManyToMany(fetch = FetchType.EAGER)
    private Set<Goods> goods = new HashSet<>();

    @ManyToMany(mappedBy = "goods")
    Set<Goods> goodsSet = new HashSet<>();

    @CreationTimestamp()
    @Column(updatable = true)
    private Date createTime;

    @UpdateTimestamp
    private Data updateTime;
}